package maxEntClassifier;
import java.io.File;

public class DirTraversal {
	
	TraversalAction ta;
	public DirTraversal(TraversalAction _ta){
		ta=_ta;
	}
	
	public void traversDir(File file) throws Exception{
		if(!file.exists()){
			System.err.println("wrong file name!");
			System.exit(-1);
			return;
		}
		if(!file.isDirectory()){
			ta.processFile(file);
			return;
		}
		ta.processDir(file);
		File[] fa=file.listFiles();
		for(int i=0;i<fa.length;i++)
			traversDir(fa[i]);	
	}
	
	public static void main(String[] args) throws Exception {
		new DirTraversal(new TraversalAction() {
			public void processFile(File f) {
				System.out.println(f.getAbsolutePath());
			}
			public void processDir(File f) {
				System.out.println(f.getAbsolutePath());
			}
		}).traversDir(new File("F:\\music\\as"));
	}
	
	public interface TraversalAction{
		public void processFile(File f) throws Exception;		
		public void processDir(File f);
	}
}
